<?php 
include("includes/code_admin.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title><?php echo SITEURL; ?> Administrator</title>
<link href="style_admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="script.js"></script>

</head>

<body>
<div id="container">
<table class="main" cellspacing="0" cellpadding="0">
  <tr>
    <td class="header">
    <!-- header start -->
    <?php include("includes/header.php");?>
    <!-- header finish -->
    </td>
  </tr>
  <tr>
    <td class="middle">&nbsp;</td>
  </tr>
  <tr>
    <td>
    <!-- tepa start -->
<?php include("includes/tepa.php"); ?>
    <!-- tepa finish -->
    </td>
  </tr>
  <tr>
    <td>
    <!-- contant start -->
<table class="content" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td>
    <!-- right col -->
<div class="right_col">
<h3 class="title">Maqola va Yangiliklarni boshqarish</h3>
<?php 
if (isset($_GET['del_id'])) {$del_id = $_GET['del_id'];}
// katalogni delete qilish
if(isset($del_id))
{
	$result2 = mysql_query("SELECT img_news FROM news WHERE id_news='$del_id'",$db);
	$myrow2 = mysql_fetch_array($result2);

	$img = "../".$myrow2['img_news'];
	if(!empty($img)) { @ unlink($img); }
	
	$result2 = mysql_query("DELETE FROM news WHERE id_news='$del_id'");
	if($result2=='true') 
	{ 
	echo "<p class='ok'>Maqola O'chirildi, OK</p>"; 
	}
	else 
	{ 
	echo "<p class='error'>XATOLIK Afsuski Yangilik o'chirilmadi, Adminga xabar bering</p>";
	}
}
?>
<div class="add_cat">
<img src="img/page.png" alt="Maqola" align="absmiddle" /> <a href="news_add.php">Yangi Maqola kiritish</a>
</div>

<table class="jadval">
<?php 
// katalogni bazadan olamiz
$result = mysql_query("SELECT id_news, title_news FROM news ORDER by id_news DESC",$db);
if (!$result)
{ myerror("News jadvalidan malumotlar olinmadi..."); }

if(mysql_num_rows($result) > 0)
{
$myrow = mysql_fetch_array($result);
do {
	printf("<tr> <td>
        <span class='news_title'>  %s) &nbsp;    %s </label></span> 
		
		<span class='view'><a href='news.php?del_id=%s' onclick='return show_del_query()'> 
		<img src='img/del.png' width='16' height='16' align='absmiddle' /> O'chirich </a></span>
		
		<span class='view'><a href='news_edit.php?id=%s'> 
		<img src='img/edit.png' width='16' height='16' align='absmiddle' /> O'zgartirish </a></span>
		
    	</td>
   	 	</tr>",  $myrow["id_news"], $myrow["title_news"], $myrow["id_news"], $myrow["id_news"]);
	}
	while($myrow = mysql_fetch_array($result));
}
else
{
echo "<p>Maqola va Yangilik mavjud emas</p>";
}
?>
</table>

</div>
	<!-- right col finish -->
    </td>
  </tr>
</table>


    <!-- contant finish -->
    </td>
  </tr>
</table>
<!-- futer start -->
<?php include("includes/futer.php"); ?>
<!-- futer finish -->
</div>
</body>
</html>
